<?php
declare (strict_types = 1);

namespace app\middleware;

use think\facade\Log;

class LogRequest
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        // $query = $request->query();
        $url = $request->url();
        $method = $request->method();
        $params = $request->param();

        $msg = sprintf("%s %s 参数: %s", $method, $url, json_encode($params, JSON_UNESCAPED_UNICODE));
        Log::write($msg, 'request');

        return $next($request);        
    }
}
